/*
 * comlan
 */

package com.promfy.ui.scroller;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.View.MeasureSpec;
import android.view.View.OnTouchListener;
import android.widget.LinearLayout;
import android.widget.Scroller;
import android.widget.TextView;

public class ScollerView extends LinearLayout implements OnTouchListener{
	 
    private TextView tv;
	private Context context;
	private Scroller scroller;
    
    public ScollerView(Context context) {
        super(context);
        this.context=context;
        init();
    }
     
    private void init()
    {
        scroller = new Scroller(context); 
        tv= new TextView(context);
        tv.setBackgroundColor(Color.YELLOW);
        addView(tv,500,400);
       // tv.setScroller(scroller);
        tv.setOnTouchListener(this);
    }

	@Override
	public boolean onTouch(View v, MotionEvent event) {
		switch (event.getAction()) {
		case MotionEvent.ACTION_DOWN:
			scroller.startScroll(v.getLeft(), v.getTop(), v.getLeft()-100, v.getTop()-100);
			invalidate();
			break;
		case MotionEvent.ACTION_UP:
						break;
		default:
			break;
		}
		return false;
	}
     
	@Override
	public void computeScroll() {
		// TODO Auto-generated method stub
		super.computeScroll();
		if(scroller.computeScrollOffset()){
			scrollTo(scroller.getCurrX(), scroller.getCurrY());
			postInvalidate();
		}
	}
     
 
  
}
